#pragma once
#include <asio.hpp>
#include "as_netbase.h"


namespace as
{
namespace net
{
class TcpClient : public std::enable_shared_from_this<TcpClient>
{
public:
	TcpClient(asio::io_context &io, const char *addr, int port);
	virtual ~TcpClient();
	static TcpClientPtr Connect(asio::io_context &io, const char *addr, int port);

	void Connect();
	void Disconnect();

	bool IsConnect();

private:
	asio::io_context &io_;
	TcpConnPtr conn_ = nullptr;
	asio::ip::tcp::endpoint addr_;
};
}
}